package com.ars.administrators;

import com.ars.db.DBTools;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;

import javax.swing.*;

public class DeleteAdministratorsController {
    DBTools p;
    @FXML
    private TextField tfAdminnistratorsName;
    private String administrators;

    @FXML
    public void deleteButtonAction() {
        administrators = tfAdminnistratorsName.getText().trim();
        if (!administrators.equals("")) {
            p = new DBTools();
            String sql = "delete from  website where name='" + administrators + "'";

            int t = p.update(sql);
            if (t != 0) {
                JOptionPane.showMessageDialog(null, "删除成功！");
            } else {
                JOptionPane.showMessageDialog(null, "删除失败！");
            }
        } else {
            JOptionPane.showMessageDialog(null, "名称不能为空，请输入！");
        }
    }

    @FXML
    public void cancelButtonAction() {
        tfAdminnistratorsName.clear();
    }
}
